﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="InNotCYQ.aspx.cs" Inherits="ReportMobile.InNotCYQ" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>非川渝区</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <link rel="Stylesheet" type="text/css" href="css/bootstrap.min.css" />
    <script type="text/javascript" src="js/jquery-1.11.3.min.js"></script>
    <script type="text/javascript" src="js/bootstrap.min.js"></script>
    <script type="text/javascript" src="js/back2top-master/back2top.js"></script>
    <link rel="Stylesheet" type ="text/css" href="js/back2top-master/back2top.css" />
    <script type="text/javascript">
        $(function () {
            Back2top.init();
            //$("table[id^='repTitle']").toggle();
            $(".panel-heading").click(function (e) {
                var hid = $(this).attr("title");
                $('#' + hid).toggle();
            });
        });
    </script>
    <style type="text/css">
        .redstrong{ font-weight:bold; color:Red;}
        h3{ font-weight:bold; }
        .jiachu {font-weight:bold;}
        .font_yellow{ color:Yellow;}
        .font_white { color:White;}
        .float_right{ float:right;}
        .font_red{ color:Red;}
        .text_center{ text-align:center;}
        .sf_panel_title{ padding-bottom:12px;}
        .margin-bottom10 { margin-bottom: 20px; }
        .backcolor_green{ background-color:Green;}
    </style>
</head>
<body class="container-fluid">
<%
    ReportMobile.inc.Common cm = new ReportMobile.inc.Common();
    //cm.SF_UserLog(Request.QueryString["uid"], "非川渝", DateTime.Now);
    Response.Write(cm.GetMenu(Request.QueryString["uid"], Request.QueryString["unitid"]));
    if (cm.msg.Length > 0) {
        Response.Write("<p class=\"alert-danger\">" + cm.msg + "</p>");
    }
%>
<!--第一次循环-->
<%
    if (dtRptGroup != null && Request.QueryString["upl"] == null) {
        for (int i = 0; i < dtRptGroup.Rows.Count; i++) {
            drRptGroup = dtRptGroup.Rows[i];
            double plQuota = 0, plQuotaScale = 0;
            if (dtQuota != null) {  //取品类定额
                for (int j = 0; j < dtQuota.Rows.Count; j++) {
                    drQuota = dtQuota.Rows[j];
                    if (drQuota["公司简称"].ToString() == drRptGroup["公司简称"].ToString()) {
                        if (drQuota["合计定额"] is DBNull) {
                            plQuota = 0;
                            plQuotaScale = 0;
                        }
                        else {
                            plQuota = Convert.ToDouble(drQuota["合计定额"]);
                            plQuotaScale = Convert.ToDouble(drRptGroup["欠款余额"]) / Convert.ToDouble(drQuota["合计定额"]);
                        }
                    }
                }
            }
%>

<h3 class="text_center jiachu"><%=drRptGroup["公司简称"].ToString()%>公司</h3>
        <div id="repDataRow" class="panel panel-success">
            <div title="repTitle<%=i %>" class="panel-heading">
                <div class="panel-title sf_panel_title"><%=string.Format("{0:f}", drRptGroup["欠款余额"])%><% if (plQuota != 0) {%>（<%=string.Format("{0:0.00%}",plQuotaScale) %>）<span class="float_right">定额：<%=plQuota %></span><%}%></div>
            </div>
            <!--严格按样式加头部、再加标题，效果要好很多-->
            <%
        if (dtDetail != null) {            
            %>
            <table id="repTitle<%=i %>" class="panel-body table table-hover table-bordered">
            <%for (int k = 0; k < dtDetail.Rows.Count; k++) {
                  drDetail = dtDetail.Rows[k];  //内循环取明细
                  if (drDetail["公司简称"].ToString() == drRptGroup["公司简称"].ToString())  //与品类比较，取与外层品类相同的明细
                  {
                    //  //取超期未还
                    //double cqwh = cm.GetExpireLimit(rptDate, drDetail["品类"].ToString(), sbCompany, drDetail["借款类型"].ToString());
                    //double cqwhScale = cqwh / Convert.ToDouble(drDetail["欠款余额"]);
                    //取借款类型定额
                    //double pllxQuota = 0;
                      string pllxQuotaScale = "";
                      string cqwh = "";
                      double cqsl = 0.00;
                      if (dtQuota != null) {  
                          for (int r = 0; r < dtQuota.Rows.Count; r++) {
                              drQuota = dtQuota.Rows[r];
                              if (drDetail["公司简称"].ToString() == drQuota["公司简称"].ToString() && drDetail["借款类型"].ToString() == "客户临时借款") {
                                  //取超期未还：借款
                                  cqsl = cm.GetExpireLimit(rptDate, drDetail["制表单位"].ToString(), "客户临时借款");
                                  cqwh = string.Format("{0:0.00%}", cm.GetExpireLimit(rptDate, drDetail["制表单位"].ToString(), "客户临时借款") / Convert.ToDouble(drDetail["欠款余额"]));
                                  //验证数据用
                                  //cqwh = string.Format("{0:0.00%}", cm.GetExpireLimit(rptDate, drDetail["制表单位"].ToString(), "客户临时借款") / Convert.ToDouble(drDetail["欠款余额"])) + "-" + cm.GetExpireLimit(rptDate, drDetail["制表单位"].ToString(), "客户临时借款") + "-" + drDetail["制表单位"].ToString() + "-" + rptDate.ToString();
                                  if (drQuota["借款定额"] is DBNull) {
                                      pllxQuotaScale = "";
                                  }
                                  else {
                                      //是否显示详细定额
                                      pllxQuotaScale = string.Format("{0:0.00%}", Convert.ToDouble(drDetail["欠款余额"]) / Convert.ToDouble(drQuota["借款定额"])) + "<br />" + string.Format("{0:f}", Convert.ToDouble(drQuota["借款定额"])) + "";
                                      //pllxQuotaScale = string.Format("{0:0.00%}", Convert.ToDouble(drDetail["欠款余额"]) / Convert.ToDouble(drQuota["借款定额"]));
                                  }
                              }
                              else if (drDetail["公司简称"].ToString() == drQuota["公司简称"].ToString() && drDetail["借款类型"].ToString() == "客户贷款") {
                                  //取超期未还：借款
                                  cqsl = cm.GetExpireLimit(rptDate, drDetail["制表单位"].ToString(), "客户贷款");
                                  cqwh = string.Format("{0:0.00%}", cm.GetExpireLimit(rptDate, drDetail["制表单位"].ToString(), "客户贷款") / Convert.ToDouble(drDetail["欠款余额"]));
                                  //验证数据用
                                  //cqwh = string.Format("{0:0.00%}", cm.GetExpireLimit(rptDate, drDetail["制表单位"].ToString(), "客户贷款") / Convert.ToDouble(drDetail["欠款余额"])) + "-" + cm.GetExpireLimit(rptDate, drDetail["制表单位"].ToString(), "客户贷款") + "-" + drDetail["制表单位"].ToString() + "-" + rptDate.ToString();
                                  if (drQuota["贷款定额"] is DBNull) {
                                      pllxQuotaScale = "";
                                  }
                                  else {
                                      //pllxQuotaScale = string.Format("{0:0.00%}", Convert.ToDouble(drDetail["欠款余额"]) / Convert.ToDouble(drQuota["贷款定额"]));
                                      //是否显示详细定额
                                      pllxQuotaScale = string.Format("{0:0.00%}", Convert.ToDouble(drDetail["欠款余额"]) / Convert.ToDouble(drQuota["贷款定额"])) + "<br />" + string.Format("{0:f}", Convert.ToDouble(drQuota["贷款定额"])) + "";
                                  }
                              }
                          }
                      }
%>
                        <tr>
                            <td width="20%"><%=drDetail["借款类型"]%></td>
                            <td width="40%"><%=string.Format("{0:f}", drDetail["欠款余额"])%></td>
                            <td width="20%"><%=pllxQuotaScale%></td>
                            <td width="20%" class="jiachu"><% if (cqsl <= 0) {
                                                   Response.Write(cqwh);
                                               }
                                               else {
                                                   Response.Write("<a class=\"redstrong\" href=\"InNotCYQ.aspx?uid=" + uId + "&unitid=3&upl=" + drDetail["制表单位"] + "&ulx=" + drDetail["借款类型"] + "&usum=" + cqsl.ToString() + "\">" + cqwh + "</a>");
                                                   //Response.Write("<a href=\"#\">" + cqwh + "</a>");
                                               }
%></td>
                        </tr>
                        <%
                }
              }
        %>
            </table><!-- repTitle i -->
        </div>
<%            
        }
        }
    }
%> <!--第1层循环-->


<!--非川渝区：超期未还明细开始-->
<%
    if (Request.QueryString["upl"] != null) {
%>
<h5><%=tmpPl %>：<%=tmpLx %></h5>
<h3>到期未还：<span class="redstrong"><%=Request.QueryString["usum"].ToString()%></span></h3>
<table class="table table-hover table-bordered">
    <tr class="jiachu backcolor_green font_white">
<%--        <td width = "20%">公司</td>--%>
        <td width = "40%">客户</td>
<%--        <td>品类</td>--%>
        <td width = "30%">到期时间</td>
        <td width = "30%">未还欠款</td>
    </tr>
<%
        //Response.Write(tmpPl + tmpLx);
        dtQuotaDetail = cm.GetExpireDetail(rptDate, tmpPl, tmpLx);
        if (dtQuotaDetail != null) {
            for (int w = 0; w < dtQuotaDetail.Rows.Count; w++) {
                drQuotaDetail = dtQuotaDetail.Rows[w];
%>
            <tr>
                <%--<td><%=drQuotaDetail["公司简称"] %></td>--%>
                <td><%=drQuotaDetail["客户名称"] %></td>
                <td><%=string.Format("{0:d}",drQuotaDetail["归还时间"]) %></td>
                <td><%=drQuotaDetail["欠款余额"] %></td>
            </tr>
<%
            }
        }
        else {
            Response.Write(cm.msg);
        }
%>
</table>
<%
    }
%>
<!--非川渝区：超期未还明细结束-->
<p class="alert alert-success redstrong">*统计截止时间 <%=rptDate%>，单位：元</p>
</body>
</html>
